//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ProcessBindingFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenameBindingProfile     = NULL;
  String* filenameOut1BindingProfile = NULL;
  String* filenameOut2BindingProfile = NULL;
  float   percentage                 = 10;
  
  if (argc < 5) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./SplitLigandFASTAProfileInto2Sets <In  File - Ligand FASTA Profile>";
    cout <<                                   " <Out First File - Ligand FASTA Profile>";
    cout <<                                   " <Out Second File - Ligand FASTA Profile>";
    cout <<                                   " <Percentage to Divide de Input>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameBindingProfile      = new String(argv[1]);
    filenameOut1BindingProfile  = new String(argv[2]);
    filenameOut2BindingProfile  = new String(argv[3]);
    percentage                  = atof(argv[4]);
    
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    cout << "         In File - Ligand FASTA Profile : " << argv[1] << endl;
    cout << "  Out First File - Ligand FASTA Profile : " << argv[2] << endl;
    cout << " Out Second File - Ligand FASTA Profile : " << argv[3] << endl;
    cout << "          Percentage to Divide de Input : " << argv[4] << endl;
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessBindingFASTAProfile* processBindingFASTAProfile = new ProcessBindingFASTAProfile ();
  
  cout << "Preparing Files..." << endl;
  processBindingFASTAProfile->FilenameBindingProfile(filenameBindingProfile);
  
  cout << "Loading the data..." << endl;
  if (!processBindingFASTAProfile->LoadBindingProfile())
    cout << "Error Loading data!" << endl;

  cout << "Splitting the Binding FASTA Profile..." << endl;
  if (!processBindingFASTAProfile->SplitDataInTwoFiles(filenameOut1BindingProfile, filenameOut2BindingProfile, percentage))
    cout << "Error Splitting the Binding FASTA Profile!" << endl;

  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processBindingFASTAProfile) delete processBindingFASTAProfile;
  
  if (filenameBindingProfile)     delete filenameBindingProfile;
  if (filenameOut1BindingProfile) delete filenameOut1BindingProfile;
  if (filenameOut2BindingProfile) delete filenameOut2BindingProfile;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

